<?php
require 'http://www.bespoke-app.com/BeSpokeAPI/instagram.class.php';

$config = array( 
'apiKey' => '72a58604b29c40fbac41ac1cb8aea560', // Your client id 
'apiSecret' => '46e8535dc9bf40d2b20d297721e2cae4', // Your client secret 
'grant_type' => 'authorization_code', 
'apiCallback' => 'http://54.235.166.43/BeSpokeAPI/Instagram/', // The redirect URI you provided when signed up for the service 
); 
$instagram = new Instagram($config);
$instagram->setAccessToken('213954948.f8d473e.7cd2054a7d834595b4171bfec64819d7');
	 
$Feed = $instagram->getUserFeed()->data;
var_dump($Feed);
$MediaList = array();
foreach ($Feed as $object) {
	array_push ($MediaList, MakeMediaArray($object, $instagram));
}

function MakeMediaArray ($object, $instagram) {
	$Media = array();
	$id = $object->id;
	
	$WebLink = $object->link;
	$full_name = $object->user->full_name;
	$created_time = $object->created_time;
	$type = $object->type;
	
	$MediaDetial = array( "Head"=>"Media", "ID"=>$id, "MediaType"=>"", "CommentCount"=>"", "WebLink"=>$WebLink, "Source"=>"Instagram", "Author"=>$full_name,"lastUpdate"=>$created_time);
	array_push( $Media, $MediaDetial );
	if((string)$type=='image') {
		$image_url = $object->images->standard_resolution->url;
			
		$MediaDetial = array( "Head"=>"Image", "ID"=>$id, "Type"=>'URL', "FileName"=>$image_url, "Description"=>"" );
		array_push( $Media, $MediaDetial );
	}
	
	
	return $Media;
}
?>